package com.baidu.controller;

import com.baidu.entity.OrderForm;
import com.baidu.service.OrderFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @描述 订单业务
 * @Author OrderFormController
 * @Date 2019/4/18 16:17
 **/
@Controller
@RequestMapping("/orderForm")
public class OrderFormController {

    @Autowired
    private OrderFormService orderFormService;

    /**
     * 添加订单
     * @param recipients
     * @param sender
     * @param companyname
     * @param state
     * @param street
     * @param element
     * @param city
     * @param county
     * @param postcode
     * @param phone
     * @param mailbox
     * @param remark
     * @param dataid
     * @return
     */
    @RequestMapping("/insertOrderForm")
    @ResponseBody
    public boolean insertOrderForm(String recipients,String sender,String companyname,String state,
                            String street,String element,String city,String county,String postcode,String phone,String mailbox,
                            String remark,String dataid){

        Integer i = orderFormService.insertOrderForm(recipients,sender,companyname,state, street,element,city,county,postcode,phone,mailbox,remark,dataid);
        if (i>0){
            return true;
        }
        return false;
    }


    /**
     * 列表查询
     * @param session
     * @param order_number
     * @return
     */
    @RequestMapping("/selectOrderFormById")
    @ResponseBody
    public OrderForm selectOrderFormById(HttpSession session,Integer order_number) {
        System.out.println(order_number);
        OrderForm orderForm = orderFormService.selectOrderFormById(order_number);
        session.setAttribute("orderForm",orderForm);
        if(orderForm!=null){
            System.out.println(orderForm);
            return orderForm;

        }
        return null;
    }
}
